<script type="text/javascript">

function compareHis(paraName){
  if(getCheckedCount(paraName)!=2)
  {
  alert("Please choose two version:");
  return ;
  }
  var parastr="doc_his_id_encrypt=";
  var paraTime=0;
  var checks=document.getElementsByName(paraName);
  for(i=0; i<checks.length; i++){
  if(checks[i].checked==true){
  if(paraTime==0){
  parastr +=checks[i].value+"&doc_his_id_encrypt=";
  }else{
  parastr +=checks[i].value;
  }
  paraTime++;
  }
  }
  document.location="/compareHis.do?"+parastr;
}

var hisArr=new Array();

function myCheck(obj)
{
  for(i=0;i<hisArr.length;i++)
  {
    if(obj==hisArr[i])return;
  }
  hisArr.push(obj);
  if(hisArr.length==3)
  {
    theCheck=hisArr.shift();
    theCheck.checked=false;
  }
}

</script>




<h1>Listing Histories</h1>

<table>
  <tr>
    <th>Version</th>
    <th>Date</th>
    <th>Creator</th>
    <th>Reason</th>
  </tr>

<% for history in @histories %>
  <tr>
    <td>
      <input name="doc_his_id" value="<%= history.edition_no %>" OnClick="javascript: myCheck(this);" type="checkbox">  
      <%=h 'Version:' + history.edition_no.to_s %>
    </td>
    <td><%=h history.created_at %></td>
    <td><%=h history.creator %></td>
    <td><%=h history.reason %> </td>
    <td><%= link_to 'Show_history'  %></td>
  </tr>
<% end %>
</table>

<br />
